package com.moyou.weichat.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.moyou.weichat.R;


/**
 * Created by Administrator on 2017/6/28 0028.
 */

public class VideoDialog extends Dialog {

    private View layoutView;

    private TextView transcribe_video;
    private TextView native_video;
    private TextView video_ds;
    private VideoDialogCall videoDialogCall;
    private ImageSelectCall imageSelectCall;

    public void setImageSelectCall(ImageSelectCall imageSelectCall) {
        this.imageSelectCall = imageSelectCall;
    }

    public void setVideoDialogCall(VideoDialogCall videoDialogCall) {
        this.videoDialogCall = videoDialogCall;
    }

    public VideoDialog(@NonNull Context context, boolean isImage) {
        super(context, R.style.MyNewAlertDialog);
        initView(context,isImage);
    }

    private void initView(Context context,boolean isImage) {
        layoutView = LayoutInflater.from(context).inflate(R.layout.dialog_video, null);
        transcribe_video = (TextView) layoutView.findViewById(R.id.transcribe_video);
        native_video = (TextView) layoutView.findViewById(R.id.native_video);
        video_ds= (TextView) layoutView.findViewById(R.id.video_ds);
        if (isImage){
            transcribe_video.setText("拍摄");
            native_video.setText("本地相册");
        }
        setContentView(layoutView);
        Window window = getWindow();
        window.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);

        show();
        native_video.setOnClickListener(v -> {
            if (isImage){
                imageSelectCall.nativePlaceBtn();
            }else {
                videoDialogCall.nativeBtn();
            }

            dismiss();
        });
        transcribe_video.setOnClickListener(v -> {
            if (isImage){
                imageSelectCall.shootBtn();
            }else {
                videoDialogCall.transcribeBtn();
            }
            dismiss();
        });
        video_ds.setOnClickListener(v -> dismiss());
    }

    public interface  ImageSelectCall{
        void shootBtn();
        void nativePlaceBtn();
    }

    public interface VideoDialogCall {
        void transcribeBtn();

        void nativeBtn();


    }
}
